package main

import (
	"fmt"
	"net"
)

func main() {
	listen, err := net.Listen("tcp", ":8888")
	if err != nil {
		panic(err)
	}

	defer listen.Close()

	conn, err := listen.Accept()
	fmt.Println(conn)
	if err != nil {
		panic(err)
	}

	var body [100]byte
	for true {
		_, err := conn.Read(body[:])
		if err != nil {
			panic(err)
		}
		fmt.Printf("收到消息: %s\n", body)

		_, err = conn.Write(body[:])
		if err != nil {
			panic(err)
		}
	}
}
